import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] num = new int[n];

        for (int i = 0; i < n; i++) {
            num[i] = scanner.nextInt();
        }

        Solution solution = new Solution();
        System.out.println(solution.triangularSum(num));
    }

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        int[][] array = new int[n][2];
        int[] dp = new int[m + 1];

        for (int i = 0; i < n; i++) {
            array[i][0] = scanner.nextInt();
            array[i][1] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            int price = array[i][0];
            int value = array[i][0] * array[i][1];
            for (int j = m; j > price; j--) {
                dp[j] = Math.max(dp[j], dp[j - price] + value);
            }
        }
        System.out.println(dp[m]);
    }
}

class Solution {
    public int triangularSum(int[] nums) {
        int n = nums.length;
        int[][] res = new int[n][n];

        res[0] = nums;

        for (int i = 1; i < n; i++) {
            for (int j = n - i - 1; j >= 0; j--) {
                res[i][j] = (res[i - 1][j] + res[i - 1][j + 1]) % 10;
            }
        }
        return res[n-1][0];
    }
}